home *** CD-ROM | disk | FTP | other *** search
- print "
- Welcome to the installer program for webdata, the easiest database program
- for the world wide web. The installer will ask you a few questions about
- your server. You should complete the worksheet included in the readme.html
- document before continuing. By pressing \'y\' you are agreeing to absolve the
- authors of all liability related to use of this program.
-
- Would you like to continue? [y,n]
- ";
- $_ = <STDIN>;
- if (/^n/i) {exit;};
-
- print "
- Choose a short name for this database:
- ";
- $dbname=<STDIN>;
- chop($dbname);
-
- $webdata = "webdata_$dbname".".cgi";
- $userform = $dbname."_form.html";
- $admin = $dbname."_admin.html";
- $memberentry = $dbname."_members.html";
- $webdatafields = $dbname."_fields.log";
- $datalog = $dbname."_data.log";
- $memberfile = $dbname."_members.log";
- $reportpref= $dbname."_report.log";
-
- print "\n\n
- CGI scripts can live in one of two places, depending on
- how your server is configured. If your server uses the
- cgi-bin directory, you will be prompted for the path
- to the cgi-bin, and this installer will move the
- program there. Otherwise, if your server allows you to execute
- CGI scripts in any directory, you can place them with
- the HTML pages in any directory under your homepage.
- ";
- print "\n
- Where will the CGI scripts live on your server?
- 1. In the cgi-bin directory
- 2. In the same directory as the HTML pages
- 3. I'm not sure
- ";
- $choice = <STDIN>;
- if ($choice==1) {&cgibin}
- elsif ($choice==2) {$dirname=$webdata}
- else {¬sure};
-
- print "\nWhat is the PATH to Perl on your machine?
- For example: /usr/bin/perl or /usr/local/bin/perl\n";
- $perlpath = <STDIN>;
- chop($perlpath);
- $_=$perlpath;
- if (!(/^\//)) {$perlpath = "/$perlpath";};
-
-
- print "\nWhat is the URL of your homepage?
- (start with http://)\n";
- $homepage = <STDIN>;
-
- $password=" ";
- until ($password eq $second) {
- if ($password ne " ") {print "Not a match, try again.\n\n"};
- print "\nWhat would you like you password to be?\n";
- $password = <STDIN>;
- print "\nPlease enter your password again.\n";
- $second = <STDIN>;
- };
-
- print "\n";
- print "Would you like visitors to be able to ADD entries to the database? (y/n)\n";
- $useradd = <STDIN>;
- chop ($useradd);
- $_=$useradd;
- if (/^y/i) {$useradd = "true"} else {$useradd = "false"};
-
- print "\n";
- print "Would you like visitors to be able to SEARCH the database? (y/n)\n";
- $usersearch = <STDIN>;
- chop ($usersearch);
- $_=$usersearch;
- if (/^y/i) {$usersearch = "true"} else {$usersearch = "false"};
-
-
- open(CGIREAD,"<webdata.cgi");
- @lines = <CGIREAD>;
- close CGIREAD;
- $now=time();
- $path = `pwd`;
- chop($path);
- $idcode=substr($now,-4);
-
- chop($homepage);
- chop($password);
-
- $lines[0]='#!'."$perlpath\n";
- $lines[7]="\$homepage=\"$homepage\"\;\n";
- $lines[8]="\$password=\"$password\"\;\n";
- $lines[9]="\$cgilocation=\"$webdata\"\;\n";
- $lines[10]="\$logfile=\'$path/$datalog\'\;\n";
- $lines[11]="\$fieldnames=\'$path/$webdatafields\'\;\n";
- $lines[12]="\$members=\'$path/$memberfile\'\;\n";
- $lines[13]="\$reportdata=\'$path/$reportpref\'\;\n";
- $lines[14]="\$code=\'$idcode\'\;\n";
-
- foreach (@lines) {
- if ((/<!--FLAG1-->/)&&($useradd eq "false")) {$_="<!--FLAG1-->\n"};
- if ((/<!--FLAG2-->/)&&($useradd eq "true")) {$_="#<!--FLAG2-->\n"};
- if ((/<!--FLAG3-->/)&&($usersearch eq "false")) {$_="<!--FLAG3-->\n"};
- if ((/<!--FLAG4-->/)&&($usersearch eq "true")) {$_="#<!--FLAG4-->\n"};
- if (/<!--FLAG5-->/) {$_="\$key=$now\; #<!--FLAG5-->\n"};
- };
-
-
- open(CGIWRITE,">$webdata");
- print CGIWRITE (@lines);
- close CGIWRITE;
-
- sub cgibin {
- $dirname="/cgi-bin/$webdata";
- $valid="false";
- while ($valid eq "false") {
- print "\nPlease enter the path to the /cgi-bin/ directory:\n";
- $pathToCgiBin = <STDIN> ;
- chop($pathToCgiBin);
- $_=$pathToCgiBin;
- if (!(/^\//)) {$pathToCgiBin = "/$pathToCgiBin";};
- if (!(/\/$/)) {$pathToCgiBin = "$pathToCgiBin/";};
- $_=qx(ls $pathToCgiBin);
- if (!(/./)) {
- print "\n\nPath is invalid. ";
- print "Try again, or press [CTRL]-c to exit.\n";
- } else {
- $valid="true";
- };
- };
- };
-
- sub notsure {
- print "
- If this is your first CGI, you need to know a little bit about
- the way your server is configured. Read through the first
- 5 pages of the CGI tutorial at http://www.webteacher.com/perltour
-
- It will help you feel a lot more comfortable with your server, and
- the Unix environment in general.
-
- The installer can attempt to locate perl and the cgi-bin on your machine.
- This could take over 20 minutes. Would you like to search for the path to
- Perl and the cgi-bin on yourmachine? [y or n]
- ";
- $_ = <STDIN>;
- if (/^y/i) {
- print "Searching for Perl....\n";
- $pearlsearch = `which perl`;
- wait();
- print ($perlsearch);
- print "\n searching for cgi-bin...\n";
- $pwd=`pwd`;
- $top = substr($pwd,0,index($pwd,'/')+1);
- print "$top\n";
-
-
- #print "Searching for cgi-bin";
- #@cgibinsearch= `find / -name cgi-bin -print |& grep -v denied`;
- #print (@cgibinsearch);
-
-
-
- } else {
- print "
- This program will now exit. You
- should run it again when you know whether your server requires the
- CGI scripts to be in the /cgi-bin/ directory or not.
- ";
- exit;
- };
- };
- print "\n
- The Installer will help you define your list of fields.
- Fields are the attributes you wish to record about each entry,
- for example, FirstName, LastName, Color, Make, Model, EntryDate,
- PartNumber, etc.
-
- Press [ENTER] when you are finished entering fields. If you make a mistake,
- press [ENTER] and choose No when asked if you are satisfied with the list.
-
- ";
-
- $tryagain="true";
- while ($tryagain eq "true") {
- $time = time();
- @fields = ("webdata$time\n");
- print "Enter a field name: ";
- $field = <STDIN>;
- push(@fields,$field);
- $morefields="true";
- while ($morefields eq "true") {
- print "Enter another field name: ";
- $field = <STDIN> ;
- push(@fields,$field);
- $_=$field;
- if (/./) {$morefields = "true"} else {$morefields = "false"};
- };
- print "\n";
- pop(@fields);
- foreach $field (@fields) {
- if (substr($field,0,7) ne 'webdata') {print "$field";};
- };
-
- print "\nAre you satisfied with the field list? (y/n)
- [Type \'y\' to keep the list, \'n\' to enter the fields again]";
- $tryagain = <STDIN>;
- $_=$tryagain;
- if (/^y/i) {$tryagain = "false"} else {$tryagain = "true"}
- };
-
- foreach (@fields) {
- chop($_);
- $_=$_."::text:20\n";
- };
- open(FIELDLIST,">$webdatafields");
- print FIELDLIST (@fields);
- close FIELDLIST;
- $command = "chmod 755 $webdatafields";
- qx($command);
-
- $rc=@fields;
- for($i=0;$i<$rc-1;$i++) {
- $row.="$i:";
- };
- chop($row);
- open(REPORT,">$reportpref");
- print REPORT ("BEIGE\n\n$row\n0\n0\n15\n0\n\n1\n");
- close REPORT;
- open(REPORT,">$memberfile");
- print REPORT ("::nopass\n");
- close REPORT;
-
-
- open(FIELDS,"<$webdatafields");
- @fields = <FIELDS>;
- close FIELDS;
-
- open(FORM,">$userform");
- $loc=$dirname."?cgifunction=user";
- print FORM ("
- <script language=\"javascript\">
- location.replace(\'$loc\')\;
- </script>
- ");
- close FORM;
- qx(chmod 755 $userform);
-
- open (ADMIN,">$admin");
- print ADMIN ("
- <HTML>
- <HEAD>
- <TITLE> Web Data Administration Password </TITLE>
- </HEAD>
-
- <BODY BGCOLOR=BEIGE onLoad=\"document.form1.password.focus()\">
- <H1 ALIGN=CENTER>
- YOU MUST HAVE A PASSWORD TO ENTER THE ADMINISTRATION SITE
- </H1>
-
- Enter password here:<BR>
- <FORM NAME=\"form1\" ACTION=\"$dirname\" METHOD=\"POST\">
- <INPUT TYPE=PASSWORD NAME=\"password\">
- <INPUT TYPE=HIDDEN NAME=\"cgifunction\" VALUE=\"admin\">
- <INPUT TYPE=SUBMIT VALUE=\"Enter\">
- </FORM>
-
- </BODY>
- </HTML>
-
- ");
- close ADMIN;
-
- open (MEMBERPAGE,">$memberentry");
- print MEMBERPAGE ("
- <HTML>
- <HEAD>
- <TITLE> Web Data Member Password </TITLE>
- </HEAD>
-
- <BODY BGCOLOR=BEIGE onLoad=\"document.form1.username.focus()\">
- <H1 ALIGN=CENTER>
- MEMBERS ENTRY PAGE.<BR>
- </H1>
-
- <TABLE BORDER=0>
- <FORM NAME=\"form1\" ACTION=\"$dirname\" METHOD=\"POST\">
- <TR><TD><B>User Name</B><TD><INPUT TYPE=TEXT NAME=\"username\" SIZE=20><BR>
- <TR><TD><B>Password</B><TD><INPUT TYPE=PASSWORD NAME=\"password\" SIZE=20><BR>
- </TABLE>
- <INPUT TYPE=SUBMIT NAME=\"cgifunction\" VALUE=\"memberpage\">
- </FORM>
- </BODY>
- </HTML>
-
- ");
- close MEMBERPAGE;
-
- qx(chmod 755 "$admin");
- qx(echo 111::Delete Me::admin > $datalog);
- qx(chmod 777 $datalog);
- qx(chmod 777 $webdatafields);
- qx(chmod 755 $webdata);
- qx(chmod 755 $memberentry);
- qx(chmod 777 $reportpref);
- qx(chmod 777 $memberfile);
- $_=$dirname;
- if (/cgi-bin/) {qx(cp $webdata "$pathToCgiBin")};
-
- open(BACKDOOR,">index.html");
- print BACKDOOR ("<script>location.replace(\'$userform\')</script>");
- close BACKDOOR;
- qx(chmod 755 index.html);
-
- print "
- Three pages have been created for your convenience in the
- current directory ($path).
-
- Guests should be linked to $userform to search your database
-
- Administrators should go to $admin to add, modify, and remove records,
- import and export, modify fields, and add members.
-
- Members with accounts can go to $memberentry to add and modify only
- their own records.
-
-
- If you have difficulty, please read the troubleshooting page at
- http://www.webteacher.com/perltour/testhelp.htm
-
- ";
-
-